/*********************************************************************
*
*  Microchip Information details dialog box.
*
**********************************************************************
* File Name:       AboutBox.java
* Complier:        JAVA version "1.6.0_20 and onwards"
* IDE :            NetBeans
*/

/*
Copyright (C) 2012-2023, Microchip Technology Inc., and its subsidiaries. All rights reserved.

The software and documentation is provided by microchip and its contributors
"as is" and any express, implied or statutory warranties, including, but not
limited to, the implied warranties of merchantability, fitness for a particular
purpose and non-infringement of third party intellectual property rights are
disclaimed to the fullest extent permitted by law. In no event shall microchip
or its contributors be liable for any direct, indirect, incidental, special,
exemplary, or consequential damages (including, but not limited to, procurement
of substitute goods or services; loss of use, data, or profits; or business
interruption) however caused and on any theory of liability, whether in contract,
strict liability, or tort (including negligence or otherwise) arising in any way
out of the use of the software and documentation, even if advised of the
possibility of such damage.

Except as expressly permitted hereunder and subject to the applicable license terms
for any third-party software incorporated in the software and any applicable open
source software license terms, no license or other rights, whether express or
implied, are granted under any patent or other intellectual property rights of
Microchip or any third party.
*/



package MicrochipMPFS;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import javax.swing.Action;

public class AboutBox extends javax.swing.JDialog {
    ImageIcon icon = new ImageIcon(getClass().getResource("/Resource/mchpIcon.png"));
    /** Creates new form AboutBox */
    public AboutBox(javax.swing.JFrame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        //setIconImage(icon.getImage());
        setIconImage(parent.getIconImage());
        icon = new ImageIcon(getClass().getResource("/Resource/mchp.png"));
        lblImage.setIcon(icon);

        AboutBoxKeyEventActionIntialization();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        lblToolName = new javax.swing.JLabel();
        lblVersion = new javax.swing.JLabel();
        lblCopyRight = new javax.swing.JLabel();
        lblCompany = new javax.swing.JLabel();
        btnOK = new javax.swing.JButton();
        lblImage = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        textAreaMPFSTool = new javax.swing.JTextArea();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("About : MPFS 2.2");
        setLocationByPlatform(true);
        setModal(true);
        setResizable(false);
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        lblToolName.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 11)); // NOI18N
        lblToolName.setText("Microchip MPFS Generator");
        getContentPane().add(lblToolName, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 5, 270, 20));

        lblVersion.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 12)); // NOI18N
        lblVersion.setText("Version 3.4.0");
        getContentPane().add(lblVersion, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 25, 220, 10));

        lblCopyRight.setText("Copyright © 2013 Microchip Technology, Inc.");
        getContentPane().add(lblCopyRight, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 40, 270, -1));

        lblCompany.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 12)); // NOI18N
        lblCompany.setText("Microchip");
        getContentPane().add(lblCompany, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 55, 120, -1));

        btnOK.setText("OK");
        btnOK.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnOKActionPerformed(evt);
            }
        });
        getContentPane().add(btnOK, new org.netbeans.lib.awtextra.AbsoluteConstraints(320, 147, 90, 20));

        lblImage.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Resource/mchp.png"))); // NOI18N
        lblImage.setText("jLabel5");
        getContentPane().add(lblImage, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 130, 170));

        textAreaMPFSTool.setEditable(false);
        textAreaMPFSTool.setColumns(20);
        textAreaMPFSTool.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 12)); // NOI18N
        textAreaMPFSTool.setRows(5);
        textAreaMPFSTool.setText("This software and source code is distributed \nunder the license provided with the Microchip\nTCP/IP Stack. For additional help, please \nrefer to the Microchip TCP/IP Stack Help file.");
        jScrollPane1.setViewportView(textAreaMPFSTool);

        getContentPane().add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 70, 280, 70));

        pack();
    }// </editor-fold>//GEN-END:initComponents
/*
    private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOKActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_btnOKActionPerformed
 */
 private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {
            // TODO add your handling code here:
            dispose();
    }
     
    private void AboutBoxKeyEventActionIntialization()
    {
        Action  ESCactionListener = new AbstractAction () {
          public void actionPerformed(ActionEvent actionEvent) {
            setVisible(false);
            dispose();
          }
        };
        KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, true);
        JComponent comp = this.getRootPane();
        comp.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(stroke, "ESCAPE");
        ActionMap actionMap = comp.getActionMap();
        actionMap.put("ESCAPE", ESCactionListener);

        /* OK button Action Solves MAC , Linux and Window enter key issue*/
        Action  OKactionListener = new AbstractAction () {
          public void actionPerformed(ActionEvent actionEvent) {
            btnOKActionPerformed(actionEvent);
          }
        };

        KeyStroke enter_ok = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, true);
        btnOK.getInputMap(JButton.WHEN_FOCUSED).put(enter_ok, "OK");
        actionMap = btnOK.getActionMap();
        actionMap.put("OK", OKactionListener);
        btnOK.setActionMap(actionMap);
    }
    /**
    * @param args the command line arguments
    */
    /*
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                AboutBox dialog = new AboutBox(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }
*/
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnOK;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel lblCompany;
    private javax.swing.JLabel lblCopyRight;
    private javax.swing.JLabel lblImage;
    private javax.swing.JLabel lblToolName;
    private javax.swing.JLabel lblVersion;
    private javax.swing.JTextArea textAreaMPFSTool;
    // End of variables declaration//GEN-END:variables

}
